﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using BLL;
using System.Data;
using DBUtility;

namespace IYASAKAReport
{
    public class PQReport : VehicleBase
    {
        public PQReport(RESULT_VEHICLE_INFO result_vehicle_info, bool bSingle)
            : base(result_vehicle_info, bSingle)
        {
            Vehicle_Info = result_vehicle_info;
            DCZZ = GetDCZZ(result_vehicle_info.HPHM, result_vehicle_info.HPZLDH);
            PassP = "合格";
            FailP = "不合格";
            TeminateP = "终止";
            InvalidP = "无效";
            PassC = "○";
            FailC = "×";
            
            
        }

        /// <summary>
        /// 结果详细信息
        /// </summary>
        public RESULT_VEHICLE_INFO Vehicle_Info { get; private set; }

        /// <summary>
        /// 单车轴重
        /// </summary>
        public string DCZZ { get; private set; }

        /// <summary>
        /// 通过
        /// </summary>
        public string PassP { get; set; }

        /// <summary>
        /// 不通过
        /// </summary>
        public string FailP { get; set; }

        /// <summary>
        /// 终止
        /// </summary>
        public string TeminateP { get; private set; }

        /// <summary>
        /// 无效
        /// </summary>
        public string InvalidP { get; private set; }
       
        #region 双怠速
        #region SDS X1
        /// <summary>
        /// 得到基本信息Table
        /// </summary>
        /// <returns></returns>
        public DataTable GetDataTableSDS_X1_Base(DataTable dtBase)
        {
            DataRow drBase = dtBase.NewRow();
            drBase["JCLSH"] = JCLSH;

            drBase["JCRQ"] = Convert.ToDateTime(Vehicle_Info.JCRQ).ToString("yyyy-MM-dd HH:mm:ss");
            drBase["CLZZCS"] = Vehicle_Info.CLZZCS;
            drBase["ZBZL"] = Convert.ToInt32(Vehicle_Info.ZBZL) + 100;
            drBase["ZZL"] = Vehicle_Info.ZZL;
            drBase["DPXH"] = Vehicle_Info.DPXH;
            drBase["QDXS"] = Vehicle_Info.QDXS;
            drBase["YJY"] = Vehicle_Info.WGJYY;
            drBase["LTQY"] = Vehicle_Info.LTQY;
            drBase["BSXLX"] = Vehicle_Info.BSXLX;
            drBase["FDJXH"] = Vehicle_Info.FDJXH;
            drBase["FDJZZCS"] = Vehicle_Info.FDJZZCS;
            drBase["FDJGS"] = Vehicle_Info.FDJGS;
            drBase["FDJPL"] = Vehicle_Info.FDJPL;
            drBase["GYFS"] = Vehicle_Info.GYFS;
            drBase["CHZHQQK"] = Vehicle_Info.CHZHQQK;
            
            drBase["LJXSLC"] = Vehicle_Info.LJXSLC;
            drBase["HPHM"] = Vehicle_Info.HPHM;
            drBase["VIN"] = Vehicle_Info.VIN;
            drBase["CCDJRQ"] = Vehicle_Info.CCDJRQ;
            drBase["SYR"] = Vehicle_Info.SYR;
            drBase["LXDH"] = Vehicle_Info.LXDH;
            drBase["DWS"] = Vehicle_Info.DWS;
            drBase["RYGG"] = Vehicle_Info.RYBH;
            drBase["SCRQ"] = Vehicle_Info.CCRQ;
            drBase["RLLB"] = Vehicle_Info.RLLB;

            drBase["CZY"] = Vehicle_Info.WQCZY;
            drBase["JSY"] = Vehicle_Info.YCY;
            drBase["JCCS"] = Vehicle_Info.JCCS;
            drBase["CLLX"] = Vehicle_Info.CLZL;
            drBase["PPXH"] = Vehicle_Info.PPXH;
            drBase["SYXZ"] = Vehicle_Info.SYXZ;
            drBase["XH"] = Vehicle_Info.LXDZ;
            drBase["HPYS"] = Vehicle_Info.HPYS;
            drBase["DCZZ"] = DCZZ;
            drBase["BGDBH"] = JCLSH.Split('-')[0];
            drBase["JCXBH"] = Vehicle_Info.JCXH.ToString();
          

            dtBase.Rows.Add(drBase);
            return dtBase;
        }

        /// <summary>
        /// 得到双怠速仪器检验部分结果
        /// </summary>
        /// <param name="dtSDS"></param>
        /// <returns></returns>
        public DataTable GetDataTableSDS_X1_YQ(DataTable dtSDS)
        {
            DataRow drSDS = dtSDS.NewRow();
            drSDS["JCLSH"] = JCLSH;

            RESULT_SDS_BLL sds_bll = new RESULT_SDS_BLL();
            foreach (var jclsh in lstJCLSH)
            {
                var sds = sds_bll.GetModel(jclsh);

                drSDS["SDSWD"] = sds.SDSWD;
                drSDS["SDSDQY"] = sds.SDSDQY;
                drSDS["SDSSD"] = sds.SDSSD;
                if (string.IsNullOrEmpty(sds.GLKQXS.Trim()) == false)
                {
                    drSDS["GLKQXS"] = sds.GLKQXS;
                    drSDS["GLKQXSSX"] = sds.GLKQXSSX;
                    drSDS["GLKQXSXX"] = sds.GLKQXSXX;
                    drSDS["GLKQXS_PD"] =base.GetPDResult(sds.GLKQXS_PD);
                }
                else
                {
                    drSDS["GLKQXS"] = Nothing;
                    drSDS["GLKQXSSX"] = Nothing;
                    drSDS["GLKQXSXX"] = Nothing;
                    drSDS["GLKQXS_PD"] = Nothing;
                }

                drSDS["DSCO"] = sds.DSCO;
                drSDS["DSHC"] = sds.DSHC;
                drSDS["DSCOXZ"] = sds.DSCOXZ;
                drSDS["DSHCXZ"] = sds.DSHCXZ;

                if (!string.IsNullOrEmpty(sds.DSCO.Trim())  && !string.IsNullOrEmpty(sds.DSCOXZ.Trim()))
                {
                    if (Convert.ToDouble(sds.DSCO) <= Convert.ToDouble(sds.DSCOXZ))
                    {
                        drSDS["DDS_PD"] = PassC;
                    }
                    else
                    {
                        drSDS["DDS_PD"] = FailC;
                    }
                }
                else
                {
                    drSDS["DDS_PD"] = FailC;
                }

                if (!string.IsNullOrEmpty(sds.DSHC.Trim())  && !string.IsNullOrEmpty(sds.DSHCXZ.Trim()))
                {
                    if (Convert.ToDouble(sds.DSHC) <= Convert.ToDouble(sds.DSHCXZ))
                    {
                        drSDS["DDSHC_PD"] = PassC;
                    }
                    else
                    {
                        drSDS["DDSHC_PD"] = FailC;
                    }
                }
                else
                {
                    drSDS["DDSHC_PD"] = FailC;
                }

                drSDS["GDSCO"] = sds.GDSCO;
                drSDS["GDSHC"] = sds.GDSHC;
                drSDS["GDSCOXZ"] = sds.GDSCOXZ;
                drSDS["GDSHCXZ"] = sds.GDSHCXZ;

                if (!string.IsNullOrEmpty(sds.GDSCO.Trim()) && !string.IsNullOrEmpty(sds.GDSCOXZ.Trim()))
                {
                    if (Convert.ToDouble(sds.GDSCO) <= Convert.ToDouble(sds.GDSCO))
                    {
                        drSDS["GDS_PD"] = PassC;
                    }
                    else
                    {
                        drSDS["GDS_PD"] = FailC;
                    }
                }
                else
                {
                    drSDS["GDS_PD"] = FailC;
                }

                if (!string.IsNullOrEmpty(sds.GDSHC.Trim()) && !string.IsNullOrEmpty(sds.GDSHCXZ.Trim()))
                {
                    if (Convert.ToDouble(sds.GDSHC) <= Convert.ToDouble(sds.GDSHCXZ))
                    {
                        drSDS["GDSHC_PD"] = PassC;
                    }
                    else
                    {
                        drSDS["GDSHC_PD"] = FailC;
                    }
                }
                else
                {
                    drSDS["GDSHC_PD"] = FailC;
                }

                drSDS["SDS_PD"] =GetPDResult(sds.SDS_PD.Trim());
                if (sds.DSCO_PD == sds.DSHC_PD && string.IsNullOrEmpty(sds.DSCO_PD) == false)
                {
                    drSDS["DSZ_PD"] = base.GetPDResult(sds.DSCO_PD.Trim());
                }
                else
                {
                    drSDS["DSZ_PD"] = FailC;
                }

                if (sds.GDSCO_PD == sds.GDSHC_PD && string.IsNullOrEmpty(sds.GDSHC_PD) == false)
                {
                    drSDS["GDSZ_PD"] = base.GetPDResult(sds.GDSCO_PD.Trim());
                }
                else
                {
                    drSDS["GDSZ_PD"] = FailC;
                }
            }

            dtSDS.Rows.Add(drSDS);
            return dtSDS;
        }

        /// <summary>
        /// 得到检测站的基本信息
        /// </summary>
        /// <param name="dtStation"></param>
        /// <returns></returns>
        public DataTable GetDataTable_StationInfo(DataTable dtStation)
        {
            DataRow dr = dtStation.NewRow();
            dr["JCLSH"] = JCLSH;
            dr["STATION_NAME"] = StationInfo.STATION_NAME;
            dr["STATION_ADDRESS"] = StationInfo.STATION_ADDRESS;
            dr["STATION_TEL"] = StationInfo.STATION_TEL;

            dtStation.Rows.Add(dr);
            return dtStation;
        }

        /// <summary>
        /// 得到设备的基本信息
        /// </summary>
        /// <param name="dtDev"></param>
        /// <returns></returns>
        public DataTable GetDataTableSDS_X1_Dev(DataTable dtDev)
        {
            DataRow dr = dtDev.NewRow();
            dr["JCLSH"] = JCLSH;
            INSPECTION_DEV_REG_INFO_BLL bll = new INSPECTION_DEV_REG_INFO_BLL();
            var info = bll.GetModelList("JCXH='" + JCXH + "' and SBLX=1 and SBMCDH='F1'");

            if (info.Length > 0)
            {
                dr["SBRZBH"] = info[0].SBRZBH;
                dr["SBMC"] = info[0].SBMC;
                dr["SBXH"] = info[0].SBXH;
                dr["SBSCC"] = info[0].SBZZC;
                dr["SBCCBH"] = info[0].SBCCBH;
            }

            dtDev.Rows.Add(dr);
            return dtDev;
        }

        /// <summary>
        /// 绑定双怠速X1
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public DataSet BindPQ_SDS_X1(DataSet ds)
        {
            DataTable dtBase = GetDataTableSDS_X1_Base(ds.Tables["DtHB_JBXX"]);
            DataTable dtYQ = GetDataTableSDS_X1_YQ(ds.Tables["DtHB_SDS"]);
            DataTable dtJCZ = GetDataTable_StationInfo(ds.Tables["DtHB_JCZ"]);
            DataTable dtDev = GetDataTableSDS_X1_Dev(ds.Tables["DtHB_YQ"]);

            return ds;
        }
        #endregion
        #endregion

        #region VMAS
        /// <summary>
        /// 得到基本信息Table
        /// </summary>
        /// <returns></returns>
        public DataTable GetDataTableVMAS_X3_Base(DataTable dtBase)
        {
            DataRow drBase = dtBase.NewRow();

            drBase["JCLSH"] = JCLSH;
            drBase["JCRQ"] = DateTime.Parse(Vehicle_Info.JCRQ).ToString("yyyy-MM-dd HH:mm:ss");
            drBase["YJY"] = Vehicle_Info.WGJYY;
            drBase["XH"] = Vehicle_Info.XH;
            drBase["CLZZCS"] = Vehicle_Info.CLZZCS;
            drBase["ZBZL"] = int.Parse(Vehicle_Info.ZBZL) + 100;
            drBase["ZZL"] = Vehicle_Info.ZZL;
            drBase["DPXH"] = Vehicle_Info.DPXH;
            drBase["QDXS"] = Vehicle_Info.QDXS;
            drBase["LTQY"] = Vehicle_Info.LTQY;
            drBase["BSXLX"] = Vehicle_Info.BSXLX;
            drBase["FDJXH"] = Vehicle_Info.FDJXH;
            drBase["FDJZZCS"] = Vehicle_Info.FDJZZCS;
            drBase["FDJGS"] = Vehicle_Info.FDJGS;
            drBase["FDJPL"] = Vehicle_Info.FDJPL;
            drBase["GYFS"] = Vehicle_Info.GYFS;
            drBase["CHZHQQK"] = Vehicle_Info.CHZHQQK;
            drBase["LJXSLC"] = Vehicle_Info.LJXSLC;
            drBase["HPHM"] = Vehicle_Info.HPHM;
            drBase["SCRQ"] = Vehicle_Info.CCRQ;
            drBase["VIN"] = Vehicle_Info.VIN;
            drBase["CCDJRQ"] = Vehicle_Info.CCDJRQ;
            drBase["SYR"] = Vehicle_Info.SYR;
            drBase["HPYS"] = Vehicle_Info.HPYS;
            drBase["LXDH"] = Vehicle_Info.LXDH;
            drBase["RYBH"] = Vehicle_Info.RYBH;
            drBase["DWS"] = Vehicle_Info.DWS;
            drBase["CZY"] = Vehicle_Info.WQCZY;
            drBase["JSY"] = Vehicle_Info.YCY;
            drBase["RLLX"] = Vehicle_Info.RLLB;
            drBase["CLLX"] = Vehicle_Info.CLZL;
            drBase["PPXH"] = Vehicle_Info.PPXH;
            drBase["SYXZ"] = Vehicle_Info.SYXZ;
            drBase["CZDZ"] = Vehicle_Info.LXDZ;
            drBase["JCCS"] = Vehicle_Info.JCCS;
            drBase["DCZZ"] = DCZZ;
            drBase["BGDBH"] = JCLSH.Split('-')[0];
            drBase["JCXBH"] = Vehicle_Info.JCXH;
            dtBase.Rows.Add(drBase);
            return dtBase;
        }
        /// <summary>
        /// 得到VMAS仪器检验部分结果
        /// </summary>
        /// <param name="dtVMAS"></param>
        /// <returns></returns>
        public DataTable GetDataTableVMAS_X3_YQ(DataTable dtVMAS)
        {
            DataRow drVMAS = dtVMAS.NewRow();

            drVMAS["JCLSH"] = JCLSH;
            RESULT_VMAS_BLL vmas_bll = new RESULT_VMAS_BLL();
            foreach (var jclsh in lstJCLSH)
            {
                var vmas = vmas_bll.GetModel(jclsh);             
                drVMAS["VMASWD"] = vmas.WD;
                drVMAS["VMASDQY"] = vmas.DQY;
                drVMAS["VMASSD"] = vmas.SD;
                drVMAS["COJG"] = vmas.COJG;
                drVMAS["COXZ"] = vmas.COXZ;
                drVMAS["CO_PD"] = base.GetPDResult(vmas.CO_PD.Trim());
                drVMAS["HCJG"] = vmas.HCJG;
                drVMAS["NOJG"] = vmas.NOJG;
                drVMAS["VMAS_PD"] = GetPDResult(vmas.CO_PD.Trim());
                int PDFS = int.Parse(vmas.PDFS);
                if (PDFS == 1)
                {
                    drVMAS["HCXZ"] = "-";
                    drVMAS["HC_PD"] = "-";
                    drVMAS["NOXZ"] = "-";
                    drVMAS["NO_PD"] = "-";
                    drVMAS["HC_NOJG"] = vmas.HC_NOJG;
                    drVMAS["HC_NOXZ"] = vmas.HC_NOXZ;
                    drVMAS["HC_NO_PD"] =base.GetPDResult(vmas.HC_NO_PD.Trim());
                }
                else if (PDFS == 0)
                {
                    drVMAS["HCXZ"] = vmas.HCXZ;
                    drVMAS["NOXZ"] = vmas.NOXZ;
                    drVMAS["HC_PD"] =base.GetPDResult(vmas.HC_PD.Trim());
                    drVMAS["NO_PD"] =base.GetPDResult(vmas.CO_PD.Trim());
                    drVMAS["HC_NOJG"] = "-";
                    drVMAS["HC_NOXZ"] = "-";
                    drVMAS["HC_NO_PD"] = "-";
                }
            }
            dtVMAS.Rows.Add(drVMAS);
            return dtVMAS;
        }
        /// <summary>
        /// 得到设备的基本信息
        /// </summary>
        /// <param name="dtDev"></param>
        /// <returns></returns>
        public DataTable GetDataTableVMAS_X3_Dev(DataTable dtDev)
        {
            DataRow dr = dtDev.NewRow();
            dr = SetDataTableDefaultValue(ref dtDev, Nothing);
            INSPECTION_DEV_REG_INFO_BLL bll = new INSPECTION_DEV_REG_INFO_BLL();
            var info = bll.GetModelList("JCXH='" + JCXH + "' and SBLX=1 and SBMCDH='G1'");
            dr["CGJXH"] = "";
            dr["FQYXH"] = "";
            dr["YDJXH"] = "";
            if (info.Length > 0)
            {
                dr["SBRZBH"] = info[0].SBRZBH;
                dr["SBMC"] = info[0].SBMC;
                dr["XH"] = info[0].SBXH;
                dr["ZZC"] = info[0].SBZZC;
                dr["CCBH"] = info[0].SBCCBH;
            }

            var infoF = bll.GetModelList("JCXH='" + JCXH + "' and SBLX=1 and SBMCDH='F1'");

            if (infoF.Length > 0)
            {

                dr["PQFXYXH"] = infoF[0].SBXH;
                dr["PQFXYZZC"] = infoF[0].SBZZC;
                dr["PQFXYCCBH"] = infoF[0].SBCCBH;
            }

            var infoL = bll.GetModelList("JCXH='" + JCXH + "' and SBLX=1 and SBMCDH='L1'");

            if (infoL.Length > 0)
            {

                dr["LLJXH"] = infoL[0].SBXH;
                dr["LLJZZC"] = infoL[0].SBZZC;
                dr["LLJCCBH"] = infoL[0].SBCCBH;
            }

            dtDev.Rows.Add(dr);
            return dtDev;
        }
        /// <summary>
        /// 绑定VMASX3
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public DataSet BindPQ_VMAS_X3(DataSet ds)
        {
            DataTable dtBase = GetDataTableVMAS_X3_Base(ds.Tables["DtHB_JBXX"]);
            DataTable dtYQ = GetDataTableVMAS_X3_YQ(ds.Tables["DtHB_STGK"]);
            DataTable dtJCZ = GetDataTable_StationInfo(ds.Tables["DtHB_JCZ"]);
            DataTable dtDev = GetDataTableVMAS_X3_Dev(ds.Tables["DtHB_YQ"]);
            return ds;
        }

      
        #endregion

        #region 不透光
        /// <summary>
        /// 得到基本信息Table
        /// </summary>
        /// <returns></returns>
        public DataTable GetDataTableBTG_X4_Base(DataTable dtBase)
        {
            DataRow drBase = dtBase.NewRow();

            drBase["HPHM"] = Vehicle_Info.HPHM;
            drBase["YJY"] = Vehicle_Info.WGJYY;
            drBase["CCDJRQ"] = Vehicle_Info.CCDJRQ;
            drBase["VIN"] = Vehicle_Info.VIN;
            drBase["PPXH"] = Vehicle_Info.PPXH;
            drBase["CLZZCS"] = Vehicle_Info.CLZZCS;
            drBase["ZBZL"] = int.Parse(Vehicle_Info.ZBZL) + 100;
            drBase["ZZL"] = Vehicle_Info.ZZL;
            drBase["FDJXH"] = Vehicle_Info.FDJXH;
            drBase["RYBH"] = Vehicle_Info.RYBH;
            drBase["JQFS"] = Vehicle_Info.JQFS;
            drBase["LJXSLC"] = Vehicle_Info.LJXSLC;
            drBase["HPYS"] = Vehicle_Info.HPYS;
            drBase["SCRQ"] = Vehicle_Info.CCRQ;
            drBase["PQHCLZZ"] = Vehicle_Info.PQHCLZZ;
            drBase["JCCZY"] = Vehicle_Info.WQCZY;
            drBase["JCJSY"] = Vehicle_Info.YCY;
            drBase["RYGG"] = Vehicle_Info.RYBH;
            drBase["BSQXS"] = Vehicle_Info.BSXLX;
            drBase["DWS"] = Vehicle_Info.DWS;
            drBase["CLLX"] = Vehicle_Info.CLZL;
            drBase["SYXZ"] = Vehicle_Info.SYXZ;
            drBase["CZDZ"] = Vehicle_Info.LXDZ;
            drBase["QDFS"] = Vehicle_Info.QDXS;
            drBase["QDLQY"] = Vehicle_Info.LTQY;
            drBase["RLLB"] = Vehicle_Info.RLLB;
            drBase["FDJZZCS"] = Vehicle_Info.FDJZZCS;
            drBase["FDJPL"] = Vehicle_Info.FDJPL;
            drBase["FDJGS"] = Vehicle_Info.FDJGS;
            drBase["LXDH"] = Vehicle_Info.LXDH;
            drBase["SYR"] = Vehicle_Info.SYR;
            drBase["JCCS"] = Vehicle_Info.JCCS;
            drBase["LXDZ"] = Vehicle_Info.LXDZ;
            drBase["JCRQ"] = DateTime.Parse(Vehicle_Info.JCRQ).ToString("yyyy-MM-dd HH:mm:ss");
            drBase["GYFS"] = Vehicle_Info.GYFS;
            drBase["BGDBH"] = JCLSH.Split('-')[0];
            drBase["JCXBH"] = Vehicle_Info.JCXH;

            dtBase.Rows.Add(drBase);
            return dtBase;
        }
        /// <summary>
        /// 得到自由加速不透光仪器检验部分结果
        /// </summary>
        /// <param name="dtBTG"></param>
        /// <returns></returns>
        public DataTable GetDataTableBTG_X4_YQ(DataTable dtBTG)
        {
            DataRow drBTG = dtBTG.NewRow();
           

            RESULT_ZYJS_BLL btg_bll = new RESULT_ZYJS_BLL();
            foreach (var jclsh in lstJCLSH)
            {
                var btg = btg_bll.GetModel(jclsh);
                drBTG["ZYJSWD"] = btg.ZYJSWD;
                drBTG["ZYJSDQY"] = btg.ZYJSDQY;
                drBTG["ZYJSSD"] = btg.ZYJSSD;
                drBTG["ZYJSDSZS"] = btg.ZYJSDSZS;
                drBTG["ZYJSJG1"] = btg.ZYJSJG1;
                drBTG["ZYJSJG2"] = btg.ZYJSJG2;
                drBTG["ZYJSJG3"] = btg.ZYJSJG3;
                drBTG["ZYJSPJZ"] = btg.ZYJSPJZ;
                drBTG["ZYJSXZ"] = btg.ZYJSXZ;
                drBTG["ZYJS_PD"] =base.GetPDResult(btg.ZYJS_PD.Trim());
                //if (btg.ZYJS_PD.Trim() == "1")
                //    drBTG["ZYJSJG4"] = "通过";
                //else
                //    drBTG["ZYJSJG4"] = "不通过";

                drBTG["ZYJSJG4"] = GetPDResult(btg.ZYJS_PD.Trim());
               
            }

            dtBTG.Rows.Add(drBTG);
            return dtBTG;
        }
        /// <summary>
        /// 得到设备的基本信息
        /// </summary>
        /// <param name="dtDev"></param>
        /// <returns></returns>
        public DataTable GetDataTableBTG_X4_Dev(DataTable dtDev)
        {
            DataRow dr = dtDev.NewRow();
            dr["JCLSH"] = JCLSH;
            INSPECTION_DEV_REG_INFO_BLL bll = new INSPECTION_DEV_REG_INFO_BLL();
            var info = bll.GetModelList("JCXH='" + JCXH + "' and SBLX=1 and SBMCDH='Y1'");

            if (info.Length > 0)
            {
                dr["SBRZBH"] = info[0].SBRZBH;
                dr["SBMC"] = info[0].SBMC;
                dr["SBXH"] = info[0].SBXH;
                dr["SBSCC"] = info[0].SBZZC;
                dr["SBCCBH"] = info[0].SBCCBH;
            }

            dtDev.Rows.Add(dr);
            return dtDev;
        }
        /// <summary>
        /// 绑定BTGX4
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public DataSet BindPQ_BTG_X4(DataSet ds)
        {
            DataTable dtBase = GetDataTableBTG_X4_Base(ds.Tables["DtHB_BTG"]);
            DataTable dtYQ = GetDataTableBTG_X4_YQ(ds.Tables["DtHB_ZYJS"]);
            DataTable dtJCZ = GetDataTable_StationInfo(ds.Tables["DtHB_JCZ"]);
            DataTable dtDev = GetDataTableBTG_X4_Dev(ds.Tables["DtHB_YQ"]);

            return ds;
        }
        #endregion

        #region 滤纸
        /// <summary>
        /// 得到基本信息Table
        /// </summary>
        /// <returns></returns>
        public DataTable GetDataTableLVZ_X6_Base(DataTable dtBase)
        {
            DataRow drBase = dtBase.NewRow();

            drBase["HPHM"] = Vehicle_Info.HPHM;
            drBase["YJY"] = Vehicle_Info.WGJYY;
            drBase["CCDJRQ"] = Vehicle_Info.CCDJRQ;
            drBase["VIN"] = Vehicle_Info.VIN;
            drBase["PPXH"] = Vehicle_Info.PPXH;
            drBase["CLZZCS"] = Vehicle_Info.CLZZCS;
            drBase["ZBZL"] = int.Parse(Vehicle_Info.ZBZL) + 100;
            drBase["ZZL"] = Vehicle_Info.ZZL;
            drBase["FDJXH"] = Vehicle_Info.FDJXH;
            drBase["RYBH"] = Vehicle_Info.RYBH;
            drBase["JQFS"] = Vehicle_Info.JQFS;
            drBase["HPYS"] = Vehicle_Info.HPYS;
            drBase["LJXSLC"] = Vehicle_Info.LJXSLC;
            drBase["PQHCLZZ"] = Vehicle_Info.PQHCLZZ;
            drBase["JCCZY"] = Vehicle_Info.WQCZY;
            drBase["JCJSY"] = Vehicle_Info.YCY;
            drBase["RYGG"] = Vehicle_Info.RYBH;
            drBase["BSQXS"] = Vehicle_Info.BSXLX;
            drBase["DWS"] = Vehicle_Info.DWS;
            drBase["CLLX"] = Vehicle_Info.CLZL;
            drBase["SYXZ"] = Vehicle_Info.SYXZ;
            drBase["CZDZ"] = Vehicle_Info.LXDZ;
            drBase["QDFS"] = Vehicle_Info.QDXS;
            drBase["QDLQY"] = Vehicle_Info.LTQY;
            drBase["SCRQ"] = Vehicle_Info.CCRQ;
            drBase["FDJPL"] = Vehicle_Info.FDJPL;
            drBase["LXDH"] = Vehicle_Info.LXDH;
            drBase["FDJSCC"] = Vehicle_Info.FDJZZCS;
            drBase["FDJGS"] = Vehicle_Info.FDJGS;
            drBase["RLLB"] = Vehicle_Info.RLLB;
            drBase["SYR"] = Vehicle_Info.SYR;
            drBase["JCCS"] = Vehicle_Info.JCCS;
            drBase["LXDZ"] = Vehicle_Info.LXDZ;
            drBase["JCRQ"] = DateTime.Parse(Vehicle_Info.JCRQ).ToString("yyyy-MM-dd HH:mm:ss");
            drBase["GYFS"] = Vehicle_Info.GYFS;
            drBase["BGDBH"] = JCLSH.Split('-')[0];
            drBase["JCXBH"] = Vehicle_Info.JCXH.ToString();

            dtBase.Rows.Add(drBase);
            return dtBase;
        }
        /// <summary>
        /// 得到自由加速滤纸仪器检验部分结果
        /// </summary>
        /// <param name="dtBTG"></param>
        /// <returns></returns>
        public DataTable GetDataTableLVZ_X6_YQ(DataTable dtLVZ)
        {
            DataRow drLVZ = dtLVZ.NewRow();


            RESULT_ZYJS_BLL lvz_bll = new RESULT_ZYJS_BLL();
            foreach (var jclsh in lstJCLSH)
            {
                var lvz = lvz_bll.GetModel(jclsh);
                drLVZ["ZYJSWD"] = lvz.ZYJSWD;
                drLVZ["ZYJSDQY"] = lvz.ZYJSDQY;
                drLVZ["ZYJSSD"] = lvz.ZYJSSD;
                drLVZ["ZYJSDSZS"] = lvz.ZYJSDSZS;
                drLVZ["ZYJSJG1"] = lvz.ZYJSJG1;
                drLVZ["ZYJSJG2"] = lvz.ZYJSJG2;
                drLVZ["ZYJSJG3"] = lvz.ZYJSJG3;
                drLVZ["ZYJSJG4"] = lvz.ZYJSJG4;
                drLVZ["ZYJSPJZ"] = lvz.ZYJSPJZ;
                drLVZ["ZYJSXZ"] = lvz.ZYJSXZ;
                drLVZ["ZYJS_PD"] = base.GetPDResult(lvz.ZYJS_PD.Trim());              
                drLVZ["Z_PD"] = GetPDResult(lvz.ZYJS_PD.Trim());

            }

            dtLVZ.Rows.Add(drLVZ);
            return dtLVZ;

        }
        /// <summary>
        /// 得到设备的基本信息
        /// </summary>
        /// <param name="dtDev"></param>
        /// <returns></returns>
        public DataTable GetDataTableLVZ_X6_Dev(DataTable dtDev)
        {
            DataRow dr = dtDev.NewRow();
            dr["JCLSH"] = JCLSH;
            INSPECTION_DEV_REG_INFO_BLL bll = new INSPECTION_DEV_REG_INFO_BLL();
            var info = bll.GetModelList("JCXH='" + JCXH + "' and SBLX=1 and SBMCDH='Y2'");

            if (info.Length > 0)
            {
                dr["SBRZBH"] = info[0].SBRZBH;
                dr["SBMC"] = info[0].SBMC;
                dr["SBXH"] = info[0].SBXH;
                dr["SBSCC"] = info[0].SBZZC;
                dr["SBCCBH"] = info[0].SBCCBH;
            }

            dtDev.Rows.Add(dr);
            return dtDev;
        }
        /// <summary>
        /// 绑定LVZX6
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public DataSet BindPQ_LVZ_X6(DataSet ds)
        {
            DataTable dtBase = GetDataTableLVZ_X6_Base(ds.Tables["DtHB_BTG"]);
            DataTable dtYQ = GetDataTableLVZ_X6_YQ(ds.Tables["DtHB_ZYJS"]);
            DataTable dtJCZ = GetDataTable_StationInfo(ds.Tables["DtHB_JCZ"]);
            DataTable dtDev = GetDataTableLVZ_X6_Dev(ds.Tables["DtHB_YQ"]);

            return ds;
        }

        #endregion

        #region 加载减速 不透光
        /// <summary>
        /// 得到基本信息Table
        /// </summary>
        /// <returns></returns>
        public DataTable GetDataTableJZJS_X5_Base(DataTable dtBase)
        {
            DataRow drBase = dtBase.NewRow();

            drBase["HPHM"] = Vehicle_Info.HPHM;
            drBase["CCDJRQ"] = Vehicle_Info.CCDJRQ;
            drBase["VIN"] = Vehicle_Info.VIN;
            drBase["PPXH"] = Vehicle_Info.PPXH;
            drBase["CLZZCS"] = Vehicle_Info.CLZZCS;
            drBase["ZBZL"] = int.Parse(Vehicle_Info.ZBZL) + 100;
            drBase["ZZL"] = Vehicle_Info.ZZL;
            drBase["FDJXH"] = Vehicle_Info.FDJXH;
            drBase["RYBH"] = Vehicle_Info.RYBH;
            drBase["JQFS"] = Vehicle_Info.JQFS;
            drBase["LJXSLC"] = Vehicle_Info.LJXSLC;
            drBase["SCRQ"] = Vehicle_Info.CCRQ;
            drBase["PQHCLZZ"] = Vehicle_Info.PQHCLZZ;
            drBase["JCCZY"] = Vehicle_Info.WQCZY;
            drBase["JCJSY"] = Vehicle_Info.YCY;
            drBase["HPYS"] = Vehicle_Info.HPYS;
            drBase["RYGG"] = Vehicle_Info.RYBH;
            drBase["BSQXS"] = Vehicle_Info.BSXLX;
            drBase["DWS"] = Vehicle_Info.DWS;
            drBase["CLLX"] = Vehicle_Info.CLZL;
            drBase["SYXZ"] = Vehicle_Info.SYXZ;
            drBase["CZDZ"] = Vehicle_Info.LXDZ;
            drBase["YJY"] = Vehicle_Info.WGJYY;
            drBase["QDFS"] = Vehicle_Info.QDXS;
            drBase["QDLQY"] = Vehicle_Info.LTQY;
            drBase["RLLB"] = Vehicle_Info.RLLB;
            drBase["FDJZZCS"] = Vehicle_Info.FDJZZCS;
            drBase["FDJPL"] = Vehicle_Info.FDJPL;
            drBase["FDJGS"] = Vehicle_Info.FDJGS;
            drBase["LXDH"] = Vehicle_Info.LXDH;
            drBase["SYR"] = Vehicle_Info.SYR;
            drBase["JCCS"] = Vehicle_Info.JCCS;
            drBase["LXDZ"] = Vehicle_Info.LXDZ;       
            drBase["JCRQ"] = DateTime.Parse(Vehicle_Info.JCRQ).ToString("yyyy-MM-dd HH:mm:ss");
            drBase["GYFS"] = Vehicle_Info.GYFS;
            drBase["BGDBH"] = JCLSH.Split('-')[0];
            drBase["JCXBH"] = Vehicle_Info.JCXH.ToString();
            dtBase.Rows.Add(drBase);
            return dtBase;
        }
        /// <summary>
        /// 得到加载减速仪器检验部分结果
        /// </summary>
        /// <param name="dtBTG"></param>
        /// <returns></returns>
        public DataTable GetDataTableJZJS_X5_YQ(DataTable dtJZJS)
        {
            DataRow drJZJS = dtJZJS.NewRow();


            RESULT_LD_BLL jzjs_bll = new RESULT_LD_BLL();
            foreach (var jclsh in lstJCLSH)
            {
                var jzjs = jzjs_bll.GetModel(jclsh);
                drJZJS["LDWD"] = jzjs.LDWD;
                drJZJS["LDDQY"] = jzjs.LDDQY;
                drJZJS["LDSD"] = jzjs.LDSD;
                drJZJS["GXSXS100"] = jzjs.GXSXS100;
                drJZJS["GXSXS90"] = jzjs.GXSXS90;
                drJZJS["GXSXS80"] = jzjs.GXSXS80;
                drJZJS["GLJG"] = jzjs.GLJG;
                drJZJS["GXSXSXZ"] = jzjs.GXSXSXZ;
                drJZJS["GLXZ"] = jzjs.GLXZ;
                drJZJS["GLPD"] = base.GetPDResult(jzjs.GL_PD.Trim());
                drJZJS["GXSXSPD"] = base.GetPDResult(jzjs.GXSXS_PD.Trim());
                drJZJS["LD_PD"] = GetPDResult(jzjs.LD_PD.Trim());

            }

            dtJZJS.Rows.Add(drJZJS);
            return dtJZJS;
        
        
        }
        /// <summary>
        /// 检测站设备
        /// </summary>
        /// <param name="dtDev"></param>
        /// <returns></returns>
        public DataTable GetDataTableJZJS_X5_Dev(DataTable dtDev)
        {
            DataRow dr = dtDev.NewRow();
            dr["JCLSH"] = JCLSH;
            INSPECTION_DEV_REG_INFO_BLL bll = new INSPECTION_DEV_REG_INFO_BLL();
            var info = bll.GetModelList("JCXH='" + JCXH + "' and SBLX=1 and SBMCDH='G1'");

            if (info.Length > 0)
            {
                dr["SBRZBH"] = info[0].SBRZBH;
                dr["SBMC"] = info[0].SBMC;
                dr["SBXH"] = info[0].SBXH;
                dr["SBSCC"] = info[0].SBZZC;
                dr["SBCCBH"] = info[0].SBCCBH;
            }

            var infoY = bll.GetModelList("JCXH='" + JCXH + "' and SBLX=1 and SBMCDH='Y1'");

            if (infoY.Length > 0)
            {
                
                dr["YDJXH"] = infoY[0].SBXH;
                dr["YDJZZC"] = infoY[0].SBZZC;
                dr["YDJCCBH"] = infoY[0].SBCCBH;
            }
            dtDev.Rows.Add(dr);
            return dtDev;
    
        }
        /// <summary>
        /// 绑定
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public DataSet BindPQ_JZJS_X5(DataSet ds)
        {
            DataTable dtBase = GetDataTableJZJS_X5_Base(ds.Tables["DtHB_BTG"]);
            DataTable dtYQ = GetDataTableJZJS_X5_YQ(ds.Tables["DtHB_JZJS"]);
            DataTable dtJCZ = GetDataTable_StationInfo(ds.Tables["DtHB_JCZ"]);
            DataTable dtDev = GetDataTableJZJS_X5_Dev(ds.Tables["DtHB_YQ"]);
    
            return ds;
        }




        #endregion

        /// <summary>
        /// 得到单车轴重
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <returns></returns>
        private string GetDCZZ(string hphm, string hpzldh)
        {
            string strRet = "";
            LOGIN_VEHICLE_INFO_BLL bll = new LOGIN_VEHICLE_INFO_BLL();
            var info = bll.GetModelList("HPHM='" + hphm + "' and HPZLDH='" + hpzldh + "'");

            if (info.Length > 0)
            {
                strRet = info[0].DCZZ;
            }
            return strRet;
        }

        /// <summary>
        /// 得到判定结果
        /// </summary>
        /// <param name="strValue"></param>
        /// <returns></returns>
        public new string GetPDResult(string strValue)
        {
            string strRet = "";
            switch (strValue.Trim())
            {
                case "1"://通过
                    strRet = PassP;
                    break;
                case "2"://未通过
                    strRet = FailP;
                    break;
                case "3":
                    strRet = NoAudit;
                    break;
                case "4":
                    strRet = TeminateP;
                    break;
                case "5":
                    strRet = InvalidP;
                    break;
                default:
                    strRet = NothingC;
                    break;
            }
            return strRet;
        }
    }
}
